/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.uccart_project.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;


@Entity
@Table(name = "nota")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Nota.findAll", query = "SELECT n FROM Nota n"),
    @NamedQuery(name = "Nota.findByNotaCodestudiante", query = "SELECT n FROM Nota n WHERE n.notaPK.notaCodestudiante = :notaCodestudiante"),
    @NamedQuery(name = "Nota.findByNotaCodcurso", query = "SELECT n FROM Nota n WHERE n.notaPK.notaCodcurso = :notaCodcurso"),
    @NamedQuery(name = "Nota.findByNotaPromedio", query = "SELECT n FROM Nota n WHERE n.notaPromedio = :notaPromedio"),
    @NamedQuery(name = "Nota.findByNotaCondicion", query = "SELECT n FROM Nota n WHERE n.notaCondicion = :notaCondicion"),
    @NamedQuery(name = "Nota.findByNotaCodestudianteCondicion", query = "SELECT n FROM Nota n WHERE n.notaPK.notaCodestudiante = :notaCodestudiante AND (n.notaCondicion= 0 OR n.notaCondicion= 1)")})
public class Nota implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected NotaPK notaPK;
    @Column(name = "nota_promedio")
    private Integer notaPromedio;
    @Column(name = "nota_condicion")
    private Integer notaCondicion;
    @JoinColumn(name = "nota_codestudiante", referencedColumnName = "est_id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Estudiante estudiante;
    @JoinColumn(name = "nota_codcurso", referencedColumnName = "curso_id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Curso curso;

    public Nota() {
    }

    public Nota(NotaPK notaPK) {
        this.notaPK = notaPK;
    }

    public Nota(String notaCodestudiante, String notaCodcurso) {
        this.notaPK = new NotaPK(notaCodestudiante, notaCodcurso);
    }

    public NotaPK getNotaPK() {
        return notaPK;
    }

    public void setNotaPK(NotaPK notaPK) {
        this.notaPK = notaPK;
    }

    public Integer getNotaPromedio() {
        return notaPromedio;
    }

    public void setNotaPromedio(Integer notaPromedio) {
        this.notaPromedio = notaPromedio;
    }

    public Integer getNotaCondicion() {
        return notaCondicion;
    }

    public void setNotaCondicion(Integer notaCondicion) {
        this.notaCondicion = notaCondicion;
    }

    public Estudiante getEstudiante() {
        return estudiante;
    }

    public void setEstudiante(Estudiante estudiante) {
        this.estudiante = estudiante;
    }

    public Curso getCurso() {
        return curso;
    }

    public void setCurso(Curso curso) {
        this.curso = curso;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (notaPK != null ? notaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Nota)) {
            return false;
        }
        Nota other = (Nota) object;
        if ((this.notaPK == null && other.notaPK != null) || (this.notaPK != null && !this.notaPK.equals(other.notaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.uccart_project.model.Nota[ notaPK=" + notaPK + " ]";
    }
    
}
